home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Localization Tools / SCM Verifier 1.0a12 / makelist < prev    next >
Encoding:
Text File  |  1992-01-24  |  4.3 KB  |  121 lines  |  [TEXT/MPS ]

  1. #
  2. #    makelist
  3. #    MPW Shell script
  4. #    Malcolm H. Teas
  5. #    Apple Computer, Inc.
  6. #
  7. #    Function:
  8. #    Help the user build a list of corresponding files from a
  9. #    master to a test disk.  It does this by generating a list
  10. #    of the files on the two disks and asking the user (via dialog
  11. #    boxes) for the names of the test files that it cannot figure out.
  12. #
  13. #    In & Outputs:
  14. #    There are two input parameters and the sole output parm is the exit status.
  15. #    The correspondences file is also generated as output.  The first input
  16. #    parm is the filename for the correspondences file.  The second is the "d"
  17. #    for "disk", or "f" for "folder" parameter telling makelist where the 
  18. #    files to search are.
  19. #
  20. #    Set the variable names.
  21. set save-echo {echo}    # echo=1 for echoing each command before execution
  22. set echo 0
  23.  
  24. set outfile "{1}"
  25. set folder     "{2}"
  26. #    Clear the outfile if it exists.
  27. if `exists "{outfile}"`
  28.     delete "{outfile}"
  29. end
  30.  
  31. #    Set the Us and localdisk variables.  These will be used later to 
  32. #    know where to look for the files to correspond.
  33. if "{folder}" == "d"        # If we're in disk mode then...
  34. #    Ask the user to select the US disk, the original from which the test
  35. #    version was made.
  36.     set USdisk "`volumes -q | getlistitem -q -m "Select the MASTER disk please:" || ∂
  37.         set sstatus {status}`"
  38.     if {sstatus} != 0                # Test for cancel button
  39.         set echo {save-echo}
  40.         exit 2
  41.     end
  42.  
  43. #    Now get the test disk.
  44.     set Localdisk "`volumes -q | getlistitem -q -m "Select the TEST disk please:" || ∂
  45.         set sstatus {status}`"
  46.     if {sstatus} != 0                # Test for cancel button
  47.         set echo {save-echo}
  48.         exit 2
  49.     end
  50. else    #    Pick from folders, not disks.
  51. #    Ask the user to select the US folder, the original from which the test
  52. #    version was made.
  53.     set USdisk "`getfilename -q -d -m "Select the MASTER folder" || ∂
  54.         set sstatus {status}`"
  55.     if {sstatus} != 0                # Test for cancel button
  56.         set echo {save-echo}
  57.         exit 2
  58.     end
  59.     set save-dir "`directory`"
  60.     directory "{USdisk}"
  61.     directory ::
  62.     set rmstring "`directory`"
  63.  
  64. #    Now get the test disk.
  65.     set Localdisk "`getfilename -q -d -m "Select the TEST folder" || ∂
  66.         set sstatus {status}`"
  67.     if {sstatus} != 0                # Test for cancel button
  68.         set echo {save-echo}
  69.         exit 2
  70.     end
  71.     directory {save-dir}
  72. end        # picked from either disks or folders.
  73.     
  74. #    Get the file list for the US disk.  The options ask for recursive
  75. #    search, full pathnames, and files only.  The output file is a temp file.
  76. files -r -f -s "{Localdisk}" > "{outfile}".local
  77.  
  78. #    Loop on the US files and prompt the user for the test files we cannot
  79. #    figure out.  Use the type and creator of the US files to search for the 
  80. #    test file.  If we find only one, it must be the file we're looking for.
  81. #    If we find more than one, ask the user for help.  The following echos are
  82. #    a little tricky, since the following scripts will depend on the format
  83. #    precisely.  Changes here mean changes there.
  84. for file in `catenate "{outfile}".local`
  85.     continue if "{file}" =~ /≈Desktop/        # Skip the desktop file.
  86.     # Search the localdisk.  The output of this files should NOT be quoted (-q).
  87.     # Remember to quote the creator to include possible trailing spaces!
  88.     files -r -f -s -q -t `catinfo -t -q "{file}"` -c "`catinfo -c -q "{file}"`" "{USdisk}" > "{outfile}".us
  89.     if `count -l "{outfile}".us` == 1    # If only one line of output...
  90.         catenate "{outfile}".us >> "{outfile}"
  91.         echo "{file}" >> "{outfile}"        # Add it now.
  92.         continue                            # And don't ask the user.
  93.     end
  94.     # If there is more than one, ask the user for help in choosing.
  95.     set tmp "`getlistitem -q -m "The Master ∂"{file}∂" is" < "{outfile}".us ∂
  96.         || set sstatus {status}`"
  97.     if {sstatus} != 0        # If cancel, then cleanup and exit.
  98.         delete "{outfile}".us "{outfile}".local
  99.         exit 2
  100.     end  # end of if cancel
  101.     echo "{tmp}" >> "{outfile}"    
  102.     echo "{file}" >> "{outfile}"            # Add the user's choice to the list.
  103. end
  104. #    If the folder option was set, we need to clean up the filelist so that it
  105. #    would appear the same as if the disk option was set.  This is so that 
  106. #    filelists from disk or folder source can be used interchangably.
  107. if "{folder}" == f
  108.     open "{outfile}"                    # Get the file.
  109.     loop
  110.         clear /{rmstring}/ "{outfile}"    # Remove directory string.
  111.         if {status} != 0                # End of list.
  112.             break
  113.         end
  114.     end
  115.     close -y "{outfile}"                # All done! (Feel better now?)
  116. end
  117.  
  118. #    Clean up and exit.
  119. delete "{outfile}".us "{outfile}".local    # Remove the temp files.
  120. set echo {save-echo}    
  121. exit 0